package com.nb.provider;


import com.nb.provider.auth.CheckSign;
import com.nb.sdk.api.goods.dto.GoodsSearchRequest;
import com.nb.sdk.api.goods.dto.GoodsSearchResponse;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping
public class GoodsController {


    @CheckSign
    @PostMapping("goods.Goods.queryWithSpec")
    //@GetMapping("goods.Goods.queryWithSpec")
    public Result<GoodsSearchResponse> goodsSearch(@RequestBody GoodsSearchRequest request){
        //System.err.println("goodsSearch，入参:"+ JSONObject.toJSONString(request));
        GoodsSearchResponse response = new GoodsSearchResponse();
        response.setTotal(2);

        List<GoodsSearchResponse.GoodsInfo> list = new ArrayList<>();
        GoodsSearchResponse.GoodsInfo goods1 = new GoodsSearchResponse.GoodsInfo();
        goods1.setGoodsNo("1001");
        goods1.setGoodsName("漯河老式辣片");
        GoodsSearchResponse.GoodsInfo goods2 = new GoodsSearchResponse.GoodsInfo();
        goods2.setGoodsNo("1002");
        goods2.setGoodsName("南德方便面");

        list.add(goods1);
        list.add(goods2);
        response.setGoodsList(list);
        return Result.ok(response);
    }
}
